

#define UP     0x1
#define DOWN   0x2
#define LEFT   0x4
#define RIGHT  0x8
#define SELECT 0x10

typedef struct
{
    unsigned char x;
    unsigned char y;
    unsigned int colourFore;
    unsigned int colourBack;
    unsigned int colourShadow;
    char text[15];
    unsigned char length;
}TextObject;

typedef struct
{
    unsigned char x;
    unsigned char y;
    unsigned char width;
    unsigned char height;
    unsigned int *graphic;
}GraphicObject;

typedef struct
{
    TextObject text;
    GraphicObject background;
    GraphicObject icon;
    unsigned char buttonType;
}ButtonObject;

typedef struct
{
    ButtonObject button;
    unsigned char isHighlighted;
    void (*selectHandler)( void );
    void (*subMenuHandler)( void );
}MenuItem;     

typedef struct
{
    MenuItem *menuItems;
    unsigned char currentMenuItem;
    unsigned char menuNavigation[8][5];
}Menu;    

void initGui( void );

/* Display menua */
void displayMenuItem( MenuItem *menuItem );
void displayMainMenu( void );
void displayModeCfgSubMenu( TextObject *title, GraphicObject *icon);
void displaySagCfgSubMenu( unsigned int sugPsi, unsigned int curSag);
void updateMainMenu( void );
void changeSelection( MenuItem *deselect, MenuItem *select );

/* Selection handlers */
void statHandler( void );
void sagCfgHandler( void );
void modeCfgHandler( void );
void shutDownHandler( void );

/* submenu handlers */
void modeSubMenu(void);
void sagSubMenu(void);
unsigned char updateModeCfgMenu(unsigned int *compression, unsigned int *rebound);
unsigned char updateSagCfgMenu( void );

void my_itoa( unsigned int n, char *s );
void stringCopy( const char *string, char *s, unsigned char length);
unsigned int getSuggestedPsi( unsigned int weight );

